package zifuIo;


import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Reader_Writer {
    //  将D:/course/02-JavaSE进阶/day01-常用类-1/笔记/第09章-java常用类.doc
    //  使用字符输入流读取，输出到day09-code/src/file/1.doc
    public static void main(String[] args) throws IOException {
        //创建流通道
        FileReader fr = null;//读取
        FileWriter fw = null;//写入
        try {
            fr = new FileReader("D:/course/02-JavaSE进阶/day01-常用类-1/笔记/第09章-java常用类.doc");
            fw = new FileWriter("day09-code/src/file/1.doc");

            int len;
            while ((len = fr.read()) != -1){
                fw.write((char)len);
                fw.flush();//刷新缓冲区
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            try {
                fr.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                fw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        
        
    }

    public static void main1(String[] args) throws IOException {
        FileReader fr = new FileReader("第09章-java常用类.txt");
        FileWriter fw = new FileWriter("1.txt");

        char[] car = new char[1024];
        int len;
        while ((len = fr.read(car)) != -1){
            fw.write(car,0,len);
            fw.flush();
        }

        fw.close();
        fr.close();
    }
}
